using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using iBeauty.BusinessObjects;

namespace iBeauty.DAL
{
	public class DiscountSettingDAO
	{
		public DiscountSettingDAO()
		{
			DbProviderHelper.GetConnection();
		}
		public List<DiscountSetting> GetDiscountSettings()
		{
			try
			{
				List<DiscountSetting> lstDiscountSettings = new List<DiscountSetting>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[DiscountType],[VisitNumber],[PayTotal],[Holiday],[DiscountMoney],[DiscountRate],[IsUse],[AccountId],[Note] FROM [DiscountSetting]",CommandType.Text);
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					DiscountSetting oDiscountSetting = new DiscountSetting();
					oDiscountSetting.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oDiscountSetting.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oDiscountSetting.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oDiscountSetting.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["DiscountType"] != DBNull.Value)
						oDiscountSetting.DiscountType = Convert.ToString(oDbDataReader["DiscountType"]);

					if(oDbDataReader["VisitNumber"] != DBNull.Value)
						oDiscountSetting.VisitNumber = Convert.ToInt32(oDbDataReader["VisitNumber"]);

					if(oDbDataReader["PayTotal"] != DBNull.Value)
						oDiscountSetting.PayTotal = Convert.ToDouble(oDbDataReader["PayTotal"]);

					if(oDbDataReader["Holiday"] != DBNull.Value)
						oDiscountSetting.Holiday = Convert.ToDateTime(oDbDataReader["Holiday"]);

					if(oDbDataReader["DiscountMoney"] != DBNull.Value)
						oDiscountSetting.DiscountMoney = Convert.ToDouble(oDbDataReader["DiscountMoney"]);

					if(oDbDataReader["DiscountRate"] != DBNull.Value)
						oDiscountSetting.DiscountRate = Convert.ToDouble(oDbDataReader["DiscountRate"]);

					if(oDbDataReader["IsUse"] != DBNull.Value)
						oDiscountSetting.IsUse = Convert.ToString(oDbDataReader["IsUse"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oDiscountSetting.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oDiscountSetting.Note = Convert.ToString(oDbDataReader["Note"]);
					lstDiscountSettings.Add(oDiscountSetting);
				}
				oDbDataReader.Close();
				return lstDiscountSettings;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public DiscountSetting GetDiscountSetting(string ID)
		{
			try
			{
				DiscountSetting oDiscountSetting = new DiscountSetting();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[DiscountType],[VisitNumber],[PayTotal],[Holiday],[DiscountMoney],[DiscountRate],[IsUse],[AccountId],[Note] FROM [DiscountSetting] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oDiscountSetting.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oDiscountSetting.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oDiscountSetting.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oDiscountSetting.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["DiscountType"] != DBNull.Value)
						oDiscountSetting.DiscountType = Convert.ToString(oDbDataReader["DiscountType"]);

					if(oDbDataReader["VisitNumber"] != DBNull.Value)
						oDiscountSetting.VisitNumber = Convert.ToInt32(oDbDataReader["VisitNumber"]);

					if(oDbDataReader["PayTotal"] != DBNull.Value)
						oDiscountSetting.PayTotal = Convert.ToDouble(oDbDataReader["PayTotal"]);

					if(oDbDataReader["Holiday"] != DBNull.Value)
						oDiscountSetting.Holiday = Convert.ToDateTime(oDbDataReader["Holiday"]);

					if(oDbDataReader["DiscountMoney"] != DBNull.Value)
						oDiscountSetting.DiscountMoney = Convert.ToDouble(oDbDataReader["DiscountMoney"]);

					if(oDbDataReader["DiscountRate"] != DBNull.Value)
						oDiscountSetting.DiscountRate = Convert.ToDouble(oDbDataReader["DiscountRate"]);

					if(oDbDataReader["IsUse"] != DBNull.Value)
						oDiscountSetting.IsUse = Convert.ToString(oDbDataReader["IsUse"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oDiscountSetting.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oDiscountSetting.Note = Convert.ToString(oDbDataReader["Note"]);
				}
				oDbDataReader.Close();
				return oDiscountSetting;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddDiscountSetting(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string DiscountType,int?VisitNumber,Double?PayTotal,DateTime?Holiday,Double?DiscountMoney,Double?DiscountRate,string IsUse,int?AccountId,string Note)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [DiscountSetting]([CreateDate],[ModifiedDate],[TimeStamp],[DiscountType],[VisitNumber],[PayTotal],[Holiday],[DiscountMoney],[DiscountRate],[IsUse],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@DiscountType,@VisitNumber,@PayTotal,@Holiday,@DiscountMoney,@DiscountRate,@IsUse,@AccountId,@Note)",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (DiscountType!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DiscountType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DBNull.Value));
				if (VisitNumber.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,VisitNumber));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,DBNull.Value));
				if (PayTotal.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,PayTotal));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,DBNull.Value));
				if (Holiday.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,Holiday));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,DBNull.Value));
				if (DiscountMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DiscountMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DBNull.Value));
				if (DiscountRate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DiscountRate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DBNull.Value));
				if (IsUse!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,IsUse));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddDiscountSetting(DiscountSetting oDiscountSetting)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [DiscountSetting]([CreateDate],[ModifiedDate],[TimeStamp],[DiscountType],[VisitNumber],[PayTotal],[Holiday],[DiscountMoney],[DiscountRate],[IsUse],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@DiscountType,@VisitNumber,@PayTotal,@Holiday,@DiscountMoney,@DiscountRate,@IsUse,@AccountId,@Note)",CommandType.Text);
				if (oDiscountSetting.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oDiscountSetting.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oDiscountSetting.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oDiscountSetting.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.DiscountType!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,oDiscountSetting.DiscountType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DBNull.Value));
				if (oDiscountSetting.VisitNumber.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,oDiscountSetting.VisitNumber));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,DBNull.Value));
				if (oDiscountSetting.PayTotal.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,oDiscountSetting.PayTotal));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,DBNull.Value));
				if (oDiscountSetting.Holiday.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,oDiscountSetting.Holiday));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.DiscountMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,oDiscountSetting.DiscountMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DBNull.Value));
				if (oDiscountSetting.DiscountRate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,oDiscountSetting.DiscountRate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DBNull.Value));
				if (oDiscountSetting.IsUse!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,oDiscountSetting.IsUse));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,DBNull.Value));
				if (oDiscountSetting.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oDiscountSetting.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oDiscountSetting.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oDiscountSetting.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateDiscountSetting(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string DiscountType,int?VisitNumber,Double?PayTotal,DateTime?Holiday,Double?DiscountMoney,Double?DiscountRate,string IsUse,int?AccountId,string Note)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [DiscountSetting] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[DiscountType]=@DiscountType,[VisitNumber]=@VisitNumber,[PayTotal]=@PayTotal,[Holiday]=@Holiday,[DiscountMoney]=@DiscountMoney,[DiscountRate]=@DiscountRate,[IsUse]=@IsUse,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (DiscountType!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DiscountType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DBNull.Value));
				if (VisitNumber.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,VisitNumber));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,DBNull.Value));
				if (PayTotal.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,PayTotal));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,DBNull.Value));
				if (Holiday.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,Holiday));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,DBNull.Value));
				if (DiscountMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DiscountMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DBNull.Value));
				if (DiscountRate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DiscountRate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DBNull.Value));
				if (IsUse!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,IsUse));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateDiscountSetting(DiscountSetting oDiscountSetting)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [DiscountSetting] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[DiscountType]=@DiscountType,[VisitNumber]=@VisitNumber,[PayTotal]=@PayTotal,[Holiday]=@Holiday,[DiscountMoney]=@DiscountMoney,[DiscountRate]=@DiscountRate,[IsUse]=@IsUse,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (oDiscountSetting.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oDiscountSetting.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oDiscountSetting.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oDiscountSetting.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.DiscountType!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,oDiscountSetting.DiscountType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountType",DbType.String,DBNull.Value));
				if (oDiscountSetting.VisitNumber.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,oDiscountSetting.VisitNumber));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@VisitNumber",DbType.Int32,DBNull.Value));
				if (oDiscountSetting.PayTotal.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,oDiscountSetting.PayTotal));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PayTotal",DbType.Double,DBNull.Value));
				if (oDiscountSetting.Holiday.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,oDiscountSetting.Holiday));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Holiday",DbType.DateTime,DBNull.Value));
				if (oDiscountSetting.DiscountMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,oDiscountSetting.DiscountMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountMoney",DbType.Double,DBNull.Value));
				if (oDiscountSetting.DiscountRate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,oDiscountSetting.DiscountRate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@DiscountRate",DbType.Double,DBNull.Value));
				if (oDiscountSetting.IsUse!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,oDiscountSetting.IsUse));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsUse",DbType.String,DBNull.Value));
				if (oDiscountSetting.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oDiscountSetting.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oDiscountSetting.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oDiscountSetting.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oDiscountSetting.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveDiscountSetting(DiscountSetting oDiscountSetting)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [DiscountSetting] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oDiscountSetting.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveDiscountSetting(string ID)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [DiscountSetting] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
